<!DOCTYPE html><html lang="zh-CN"><head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width">
  <title>months()/weekdays() | Moment.js &#x6587;&#x6863;</title>
  <link rel="stylesheet" href="static/css/style.css">
  <link rel="shortcut icon" href="http://momentjs.cn/static/img/moment-favicon.png">
  <link rel="stylesheet" href="static/css/atom-one-light.min.css">
</head>
<body class="is-moment">
  <div class="hero hero-oneline">
    <div class="hero-centered">
      <h1>months()/weekdays()</h1>
    </div>
  </div>
  <div id="api-section-__FILENAME__">
    <div id="content" class="clearfix">
  
      <div id="column1" data-id="__ID__" class="interior">
        <header>
          <!-- <h1>months()/weekdays()</h1> -->
          <div id="gtoc">
            <ul>
              <!-- <li>v</li> -->
              <li>
                <a href="index.html#/i18n/listing-months-weekdays/" name="toc">&#x8FD4;&#x56DE;&#x4E0A;&#x5C42;&#x6587;&#x6863;</a>
              </li>
              <li style="border: none;">
                <a href="javascript:window.open('https://github.com/momentjscn/moment-docs-cn/edit/master/moment/06-i18n/07-listing-months-weekdays.md');" rel="nofollow" target="_blank">&#x63D0;&#x4EA4;&#x4FEE;&#x6539;</a>
              </li>
              <!-- <li>
                <a href="/search__SEARCH_PARAM__" name="toc">搜索</a>
              </li> -->
            </ul>
          </div>
          <hr>
        </header>

        <div id="biz_item"></div>
  
        <div id="apicontent">
          <div id="content_left">
							<div class="docs-method-signature">
								<pre><code class="language-js">moment.months()
moment.monthsShort()
moment.weekdays()
moment.weekdaysShort()
moment.weekdaysMin()
</code></pre>

							</div>
<p>&#x6709;&#x65F6;&#x9700;&#x8981;&#x5728;&#x8BED;&#x8A00;&#x73AF;&#x5883;&#x4E2D;&#x83B7;&#x53D6;&#x6708;&#x4EFD;&#x6216;&#x5DE5;&#x4F5C;&#x65E5;&#x7684;&#x5217;&#x8868;&#xFF0C;&#x4F8B;&#x5982;&#x5F53;&#x586B;&#x5145;&#x4E0B;&#x62C9;&#x83DC;&#x5355;&#x65F6;&#x3002;</p>
<pre><code class="language-javascript">moment.months();
</code></pre>
<p>&#x8FD4;&#x56DE;&#x5F53;&#x524D;&#x8BED;&#x8A00;&#x73AF;&#x5883;&#x4E2D;&#x7684;&#x6708;&#x4EFD;&#x5217;&#x8868;&#x3002;</p>
<pre><code class="language-javascript">[ &apos;January&apos;,
  &apos;February&apos;,
  &apos;March&apos;,
  &apos;April&apos;,
  &apos;May&apos;,
  &apos;June&apos;,
  &apos;July&apos;,
  &apos;August&apos;,
  &apos;September&apos;,
  &apos;October&apos;,
  &apos;November&apos;,
  &apos;December&apos; ]
</code></pre>
<p>&#x540C;&#x6837;&#xFF0C;<code>moment.monthsShort</code> &#x8FD4;&#x56DE;&#x7F29;&#x5199;&#x7684;&#x6708;&#x4EFD;&#x540D;&#x79F0;&#xFF0C;<code>moment.weekdays</code>&#x3001;<code>moment.weekdaysShort</code>&#x3001;<code>moment.weekdaysMin</code> &#x8FD4;&#x56DE;&#x5DE5;&#x4F5C;&#x65E5;&#x7684;&#x5217;&#x8868;&#x3002;</p>
<p>&#x53EF;&#x4EE5;&#x5C06;&#x6574;&#x6570;&#x4F20;&#x7ED9;&#x6BCF;&#x4E2A;&#x51FD;&#x6570;&#x4EE5;&#x83B7;&#x53D6;&#x7279;&#x5B9A;&#x7684;&#x6708;&#x4EFD;&#x6216;&#x5DE5;&#x4F5C;&#x65E5;&#x3002;</p>
<pre><code class="language-javascript">moment.weekdays(3); // &apos;Wednesday&apos;
</code></pre>
<p>&#x4ECE; <strong>2.13.0</strong> &#x5F00;&#x59CB;&#xFF0C;&#x53EF;&#x4EE5;&#x5C06;&#x5E03;&#x5C14;&#x503C;&#x4F5C;&#x4E3A; weekday &#x51FD;&#x6570;&#x7684;&#x7B2C;&#x4E00;&#x4E2A;&#x53C2;&#x6570;&#x4F20;&#x5165;&#x3002;
&#x5982;&#x679C;&#x4E3A; <code>true</code>&#xFF0C;&#x5219;&#x5C06;&#x4F1A;&#x6309;&#x7279;&#x5B9A;&#x4E8E;&#x8BED;&#x8A00;&#x73AF;&#x5883;&#x7684;&#x987A;&#x5E8F;&#x8FD4;&#x56DE;&#x5DE5;&#x4F5C;&#x65E5;&#x3002;
&#x4F8B;&#x5982;&#xFF0C;&#x5728;&#x963F;&#x62C9;&#x4F2F;&#x8BED;&#x8A00;&#x73AF;&#x5883;&#x4E2D;&#xFF0C;&#x661F;&#x671F;&#x516D;&#x662F;&#x4E00;&#x5468;&#x7684;&#x7B2C;&#x4E00;&#x5929;&#xFF0C;&#x56E0;&#x6B64;&#xFF1A;</p>
<pre><code class="language-javascript">moment.locale(&apos;ar&apos;);
moment.weekdays(true); // &#x4EE5;&#x963F;&#x62C9;&#x4F2F;&#x8BED;&#x5217;&#x51FA;&#x5468;&#x516D;&#x81F3;&#x5468;&#x4E94;&#x7684;&#x5DE5;&#x4F5C;&#x65E5;&#x5217;&#x8868;
moment.weekdays(true, 2); // &#x5C06;&#x4F1A;&#x4EE5;&#x963F;&#x62C9;&#x4F2F;&#x8BED;&#x8FD4;&#x56DE;&#x661F;&#x671F;&#x4E00;
</code></pre>
<p>&#x6CE8;&#x610F;&#xFF1A;&#x5982;&#x679C;&#x7F3A;&#x5C11;&#x8BED;&#x8A00;&#x73AF;&#x5883;&#x7279;&#x5B9A;&#x7684;&#x53C2;&#x6570;&#xFF0C;&#x5219;&#x65E0;&#x8BBA;&#x661F;&#x671F;&#x51E0;&#x662F;&#x672C;&#x5730;&#x7684;&#x7B2C;&#x4E00;&#x5929;&#xFF0C;&#x5DE5;&#x4F5C;&#x65E5;&#x59CB;&#x7EC8;&#x5C06;&#x661F;&#x671F;&#x65E5;&#x4F5C;&#x4E3A;&#x7D22;&#x5F15; 0&#x3002;</p>
<p>&#x5F53;&#x683C;&#x5F0F;&#x5316;&#x6708;&#x4EFD;&#x540D;&#x79F0;&#x65F6;&#xFF0C;&#x67D0;&#x4E9B;&#x8BED;&#x8A00;&#x73AF;&#x5883;&#x4F1A;&#x7279;&#x522B;&#x8003;&#x8651;&#x3002;
&#x4F8B;&#x5982;&#xFF0C;&#x8377;&#x5170;&#x8BED;&#x683C;&#x5F0F;&#x5316;&#x6708;&#x4EFD;&#x7684;&#x7F29;&#x5199;&#x65F6;&#x4E0D;&#x5E26;&#x672B;&#x5C3E;&#x7684;&#x53E5;&#x53F7;&#xFF0C;&#x4F46;&#x524D;&#x63D0;&#x662F;&#x683C;&#x5F0F;&#x5316;&#x7834;&#x6298;&#x53F7;&#x4E4B;&#x95F4;&#x7684;&#x6708;&#x4EFD;&#x3002;
<code>months</code> &#x65B9;&#x6CD5;&#x652F;&#x6301;&#x4F20;&#x5165;&#x683C;&#x5F0F;&#xFF0C;&#x4EE5;&#x4FBF;&#x5728;&#x9002;&#x5F53;&#x7684;&#x4E0A;&#x4E0B;&#x6587;&#x4E2D;&#x5217;&#x51FA;&#x6708;&#x4EFD;&#x3002;</p>
<pre><code class="language-javascript">moment.locale(&apos;nl&apos;);
moment.monthsShort(); // [&apos;jan.&apos;, &apos;feb.&apos;, &apos;mrt.&apos;, ...]
moment.monthsShort(&apos;-MMM-&apos;); // [ &apos;jan&apos;, &apos;feb&apos;, &apos;mrt&apos;, ...]
</code></pre>
<p>&#x6700;&#x540E;&#xFF0C;&#x53EF;&#x4EE5;&#x7ED3;&#x5408;&#x4F7F;&#x7528;&#x683C;&#x5F0F;&#x9009;&#x9879;&#x548C;&#x6574;&#x6570;&#x9009;&#x9879;&#x3002;</p>
<pre><code class="language-javascript">moment.monthsShort(&apos;-MMM-&apos;, 3); // &apos;apr&apos;
</code></pre>
					</div>
          <div id="content_right">
							<div class="docs-method-signature">
								<pre><code class="language-js">moment.months()
moment.monthsShort()
moment.weekdays()
moment.weekdaysShort()
moment.weekdaysMin()
</code></pre>

							</div>
<p>It is sometimes useful to get the list of months or weekdays in a locale, for example when populating a dropdown menu.</p>
<pre><code class="language-javascript">moment.months();
</code></pre>
<p>Returns the list of months in the current locale.</p>
<pre><code class="language-javascript">[ &apos;January&apos;,
  &apos;February&apos;,
  &apos;March&apos;,
  &apos;April&apos;,
  &apos;May&apos;,
  &apos;June&apos;,
  &apos;July&apos;,
  &apos;August&apos;,
  &apos;September&apos;,
  &apos;October&apos;,
  &apos;November&apos;,
  &apos;December&apos; ]
</code></pre>
<p>Similarly, <code>moment.monthsShort</code> returns abbreviated month names, and <code>moment.weekdays</code>, <code>moment.weekdaysShort</code>, <code>moment.weekdaysMin</code> return lists of weekdays.</p>
<p>You can pass an integer into each of those functions to get a specific month or weekday.</p>
<pre><code class="language-javascript">moment.weekdays(3); // &apos;Wednesday&apos;
</code></pre>
<p>As of <strong>2.13.0</strong> you can pass a bool as the first parameter of the weekday functions. If true, the weekdays will be returned in locale specific order.
For instance, in the Arabic locale, Saturday is the first day of the week, thus:</p>
<pre><code class="language-javascript">moment.locale(&apos;ar&apos;);
moment.weekdays(true); // lists weekdays Saturday-Friday in Arabic
moment.weekdays(true, 2); //will result in Monday in Arabic
</code></pre>
<p><strong>Note:</strong> Absent the locale specific parameter, weekdays always have Sunday as index 0, regardless of the local first day of the week.</p>
<p>Some locales make special considerations into account when formatting month names. For example, Dutch formats month abbreviations without a trailing period, but only if it&apos;s formatting the month between dashes. The <code>months</code> method supports passing a format in so that the months will be listed in the proper context.</p>
<pre><code class="language-javascript">moment.locale(&apos;nl&apos;);
moment.monthsShort(); // [&apos;jan.&apos;, &apos;feb.&apos;, &apos;mrt.&apos;, ...]
moment.monthsShort(&apos;-MMM-&apos;); // [ &apos;jan&apos;, &apos;feb&apos;, &apos;mrt&apos;, ...]
</code></pre>
<p>And finally, you can combine both the format option and the integer option.</p>
<pre><code class="language-javascript">moment.monthsShort(&apos;-MMM-&apos;, 3); // &apos;apr&apos;
</code></pre>
					</div>
          <div></div>
        </div>
      </div>
    </div>
  </div>
  
  <script src="static/js/highlight.min.js"></script>
  <script src="static/js/javascript.min.js"></script>
  <script>hljs.initHighlightingOnLoad();</script>
  <script>var _hmt = _hmt || []; (function () { var hm = document.createElement("script"); hm.src = "//hm.baidu.com/hm.js?7a7f78c805fbacc7e075d34f153031aa"; var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(hm, s); })();</script>

  <style>
    .hero-centered {
      margin: 0;
          margin-left: 10px;
    }
#gtoc ul {
  list-style: none;
  margin-left: 0;
  line-height: 1.5rem;
  padding: 0;
}
#gtoc>ul>li {
  display: inline;
  border-right: 1px solid #000;
  margin-right: .4rem;
  padding-right: .4rem;
}
#gtoc>ul>li>a {
  color: #61b2a7;
}
#content_left {
  width: 49%;float: left;border-right: 1px solid #eee;    padding-right: 2%;
}
#content_right {
float: left;width: 48%;margin-left: 3%;
}
#column1 {
  padding: 0 2rem;
}
  </style>


</body></html>